<template>
	<div>

		<el-form ref="form" :model="form" label-width="80px">

			<el-form-item label="姓名" prop="name">
				<el-input v-model="form.name"></el-input>
			</el-form-item>
			<el-form-item label="病因" prop="pathogen">
				<el-input v-model="form.pathogen"></el-input>
			</el-form-item>
			<el-form-item label="治疗处方" prop="therapeuticRegimen">
				<el-input v-model="form.therapeuticRegimen"></el-input>
			</el-form-item>
			<el-form-item label="主治医生" prop="doctor">
				<el-input v-model="form.doctor"></el-input>
			</el-form-item>
			<el-form-item label="治疗医师" prop="physician">
				<el-input v-model="form.physician"></el-input>
			</el-form-item>
			<el-form-item label="开始时间" prop="startTime">
				<!-- <el-input v-model="form.startTime"></el-input> -->
				<el-date-picker v-model="form.startTime" format="yyyy-MM-dd"  value-format="yyyy-MM-dd"
					:style="{width: '100%'}" placeholder="请输入时间" clearable>
				</el-date-picker>
			
			</el-form-item>
			<el-form-item label="预计康复周期" prop="kfPeriod">
				<el-input v-model="form.kfPeriod"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		name: 'KfProgramEdit',
		components: {

		},
		props: ['editkfId'],
		data() {
			return {
				form: {
					name: '',
					pathogen: '',
					therapeuticRegimen: '',
					doctor: '',
					physician: '',
					startTime:null,
					kfPeriod:''
				},
				url: '/kfProgram/add'
			}
		},
		created() {
			console.log("this.editkfId:" + this.editkfId)
			if (this.editkfId) {
				this.url ='/kfProgram/update'
				this.axios.get('/kfProgram/toedit', resp => {
					this.form.kfId = resp.obj.kfId
					this.form.name = resp.obj.name
					this.form.pathogen = resp.obj.pathogen
					this.form.therapeuticRegimen = resp.obj.therapeuticRegimen
					this.form.doctor = resp.obj.doctor
					this.form.physician = resp.obj.physician
					this.form.startTime = resp.obj.startTime
					this.form.kfPeriod = resp.obj.kfPeriod
				}, {
					kfId: this.editkfId
				})
			}
		},
		methods: {

			save() {
				this.$refs['form'].validate((valid) => {
					if (valid) {
						this.axios.post(this.url, response => {
							// 子组件要改变父组件的值
							this.$emit('update:show', false)
							this.$emit('getData')
						}, this.form)
					}
				})
			}
		}
	}
</script>
<style>
</style>
